<form name="frmModal" method="post" action="proc/admin/nilai.php">
<input type="hidden" value="nilai-edit" name="proc" />
<h2 class="dialog_title"><span>Add Nilai</span></h2>
<div class="dialog_content">
<div style="border-bottom: 1px solid #CCC">
<?php $res_nilai = mysql_fetch_assoc(nilai_load($nilai_id))?>
<?php $res_rnp = mysql_fetch_assoc(rnp_load($res_nilai['REWARD_ID']))?>
<?php $res_deprepel = mysql_fetch_assoc(deprepel_load($res_nilai['DETACHIEV_ID']))?>
<?php $res_prepel = mysql_fetch_assoc(perpel_load($res_deprepel['ACHIEV_ID']))?>

<table width="100%" border="0" cellpadding="5" cellspacing="0">
	<tr>
	  <td align="right">Nilai ID :</td>
	  <td><input name="nilai_id" type="text" maxlength="4" readonly="readonly" value="<?php echo $res_nilai['NILAI_ID']?>" />
	  </tr>
	<tr>
	  <td width="35%" align="right">Tipe Pres/Pel </td>
	  <td><?php $jenis = $res_prepel['ACHIEV_JENIS']?>
      	<select name="achiev_jenis" id="achiev_jenis" onchange="doAdd_bidangCombo(this.value, $('achiev_bidang'))">
	    <option value="prestasi" <?php echo strtolower($res_prepel['ACHIEV_JENIS'])==='prestasi'? "selected=\"selected\"" : ""?> >Prestasi</option>
	    <option value="pelanggaran" <?php echo strtolower($res_prepel['ACHIEV_JENIS'])==='pelanggaran'? "selected=\"selected\"" : ""?>>Pelanggaran</option>
	    </select></td>
	  </tr>
	<tr>
	  <td align="right">Bidang Pres/Pel :</td>
	  <td>
      	<select id="achiev_bidang" onchange="doAdd_tingkatCombo($('achiev_jenis').value, this.value, $('detachiev_tingkat'))">
	    <?php $res = perpel_select2(false, "ACHIEV_JENIS='$jenis'", "ACHIEV_BIDANG ASC", "ACHIEV_BIDANG"); ?>
	    <?php while($row = mysql_fetch_assoc($res)): ?>
        <?php 	$bidang = strtolower($row['ACHIEV_BIDANG'])===strtolower($res_prepel['ACHIEV_BIDANG']) ? $row['ACHIEV_BIDANG']: $bidang ?>
	    <option value="<?php echo $row['ACHIEV_BIDANG']?>" <?php echo $row['ACHIEV_BIDANG']===$res_prepel['ACHIEV_BIDANG']? "selected=\"selected\"":""?>><?php echo $row['ACHIEV_BIDANG']?></option>
	    <?php endwhile;?>
	    </select></td>
	  </tr>
	<tr>
	  <td align="right">Tingkat Pres/Pel : </td>
	  <td>
	    <select id="detachiev_tingkat" onchange="doAdd_kategoriCombo($('achiev_jenis').value, $('achiev_bidang').value, this.value, $('detachiev_id'))">
	      <?php $grp = deprepel_select_corelate(false, "a.ACHIEV_JENIS='$jenis' AND a.ACHIEV_BIDANG='$bidang'", "DETACHIEV_TINGKAT ASC", "DETACHIEV_TINGKAT");?>
	      <?php while ($grp_r = mysql_fetch_assoc($grp)): ?>
	      <?php $tingkat = strtolower($grp_r['DETACHIEV_TINGKAT'])===strtolower($res_deprepel['DETACHIEV_TINGKAT'])? $grp_r['DETACHIEV_TINGKAT'] : $tingkat ?>
	      <option value="<?php echo $grp_r['DETACHIEV_TINGKAT']?>" <?php echo $grp_r['DETACHIEV_TINGKAT']===$res_deprepel['DETACHIEV_TINGKAT']? "selected=\"selected\"" : ""?>><?php echo $grp_r['DETACHIEV_TINGKAT']?></option>
	      <?php endwhile; ?>
	      </select>
	    </td>
	  </tr>
	<tr>
	  <td align="right">Kategori Pres/Pel : </td>
	  <td>
      <select id="detachiev_id" name="detachiev_id">
      	<?php $grp = deprepel_select_corelate(false, "a.ACHIEV_JENIS='$jenis' AND a.ACHIEV_BIDANG='$bidang' AND DETACHIEV_TINGKAT='$tingkat'", "DETACHIEV_NAMA ASC", "DETACHIEV_NAMA"); ?>
	      <?php while ($grp_r = mysql_fetch_assoc($grp)): ?>
	      <option value="<?php echo $grp_r['DETACHIEV_ID']?>" <?php echo $grp_r['DETACHIEV_ID']===$res_deprepel['DETACHIEV_ID']? "selected=\"selected\"" : ""?>><?php echo $grp_r['DETACHIEV_NAMA']?></option>
	      <?php endwhile; ?>
      </select></td>
	  </tr>
	<tr>
	  <td align="right">Tipe R/P  :</td>
	  <td><?php $reward=$res_rnp['REWARD_JENIS'];?>
      	<select id="reward_jenis" onchange="doAdd_rewardCombo(this.value, $('reward_id'))">
      		<option value="reward" <?php echo strtolower($res_rnp['REWARD_JENIS'])==='reward'? "selected=\"selected\"":""?>>Reward</option>
            <option value="punishment" <?php echo strtolower($res_rnp['REWARD_JENIS'])==='punishment'? "selected=\"selected\"":""?> disabled="disabled">Punishment</option>
          </select>
	    </td>
	  </tr>
	<tr>
	  <td align="right">Kategori R/P : </td>
	  <td>
      	<select name="reward_id" id="reward_id">
	      <?php $rnp = rnp_select2(false, "REWARD_JENIS='$reward'", "REWARD_NAMA ASC"); ?>
	      <?php while ($row = mysql_fetch_assoc($rnp)):?>
	      <option value="<?php echo $row['REWARD_ID'] ?>" <?php echo strtolower($row['REWARD_ID'])===strtolower($res_rnp['REWARD_ID'])? "selected=\"selected\"":""?>><?php echo $row['REWARD_NAMA'] ?></option>
	      <?php endwhile;?>
	    </select>
      </td>
	  </tr>
	<tr>
	  <td align="right">Point :</td>
	  <td><div id="nilai_point" currentValue="<?php echo $res_nilai['NILAI_POINT']?>"></div></td>
	  </tr>
	<tr>
	  <td align="right">Range Min : </td>
	  <td align="left"><div id="nilai_min" currentValue="<?php echo $res_nilai['NILAI_MIN']?>"></div></td>
	  </tr>
	<tr>
	  <td align="right">Range Max : </td>
	  <td align="left"><div id="nilai_max" currentValue="<?php echo $res_nilai['NILAI_MAX']?>"></div></td>
	  </tr>
	</table>

</div>
<div class="dialog_buttons"><input type="button" value="Save"
	name="save" onclick="doSave($(this).getParent('form')); FBModal_hide()" />
<input type="button" value="Close" name="close" onclick="FBModal_hide()" />
</div>
</div>
</form>